﻿using Domain.Entities.AuditTrails;
using FluentMigrator;
using FrameworkCore.Extensions;

namespace Domain.Migrations.AuditTrails;

[Migration(202412251931)]
public class AuditTrailAddColumn : ForwardOnlyMigration
{
    public override void Up()
    {
        Alter.Table(MigrationExpressions.GetTableName(typeof(AuditTrail)))
          .AddColumn(MigrationExpressions.ColumnNameFor<AuditTrail>(nameof(AuditTrail.AuditType))).AsString(10).Nullable().WithColumnDescription("审计类型")
          .AddColumn(MigrationExpressions.ColumnNameFor<AuditTrail>(nameof(AuditTrail.AffectedColumns))).AsString(int.MaxValue).Nullable().WithColumnDescription("修改后的行")
          .AddColumn(MigrationExpressions.ColumnNameFor<AuditTrail>(nameof(AuditTrail.TableName))).AsString(255).Nullable().WithColumnDescription("表名")
          .AddColumn(MigrationExpressions.ColumnNameFor<AuditTrail>(nameof(AuditTrail.OldValues))).AsString(int.MaxValue).Nullable().WithColumnDescription("旧值")
          .AddColumn(MigrationExpressions.ColumnNameFor<AuditTrail>(nameof(AuditTrail.NewValues))).AsString(int.MaxValue).Nullable().WithColumnDescription("新值")
          .AddColumn(MigrationExpressions.ColumnNameFor<AuditTrail>(nameof(AuditTrail.PrimaryKey))).AsString(255).Nullable().WithColumnDescription("主键")
          .AddColumn(MigrationExpressions.ColumnNameFor<AuditTrail>(nameof(AuditTrail.DebugView))).AsString(int.MaxValue).Nullable().WithColumnDescription("调式工具")
          .AddColumn(MigrationExpressions.ColumnNameFor<AuditTrail>(nameof(AuditTrail.ErrorMessage))).AsString(int.MaxValue).Nullable().WithColumnDescription("错误消息");
    }
}
